
	var rootPath = getRootPath();
$(document).ready(function(){
	
	var resnId = getQueryParamValue("resnId");
	$("#resnId").val(resnId);
	
	
	$.ajax({
		headers: {'Cookie' : document.cookie },
		method : 'get',
		url : rootPath+'/maintain/api/v1/repairs/'+resnId,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			//alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(maintainIndex,maintainObj){
				
				var maintainHtml = '';
				
				if(maintainObj.reseApplStartTime == null){
					reseApplStartTime = " ";
				}else{
					reseApplStartTime = maintainObj.reseApplStartTime 
				}
				if(maintainObj.createDate == null){
					createDate = " ";
				}else{
					createDate = maintainObj.createDate 
				}
				if(maintainObj.reseApplEndTime == null){
					reseApplEndTime = " ";
				}else{
					reseApplEndTime = maintainObj.reseApplEndTime 
				}
				if(maintainObj.dealerName == null){
					dealerName = " ";
				}else{
					dealerName = maintainObj.dealerName 
				}
				if(maintainObj.detailAddress == null){
					detailAddress = " ";
				}else{
					detailAddress = maintainObj.detailAddress 
				}
				if(maintainObj.serviceHotline == null){
					serviceHotline = " ";
				}else{
					serviceHotline = maintainObj.serviceHotline 
				}
				
				if(maintainObj.status=="待养修"||maintainObj.status=="待确认"){
					
					maintainHtml = maintainHtml 	  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +     '<li class="list-group-item">'
					  								  +	      '<p>'
					  								  +		    '<span>'+ maintainObj.oddNumber +'</span>'
					  								  +		    '<span style="font-family:黑体;font-size:15px;color:#F15C5C;float:right">'+ maintainObj.status +'</span>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +     '<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">销售服务店：</span><span>'+ dealerName +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">地址：</span><span>'+ detailAddress +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">电话：</span><span>'+ serviceHotline +'</span>'
					  								  +			'<a href="tel:'+ maintainObj.serviceHotline +'" id="Tel">'
					  								  + 		'<span class="glyphicon glyphicon-earphone" style="padding:0 0 0 10px;color: rgb(255, 0, 23); font-size: 12px;"></span>'
					  								  + 		'</a>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">服务顾问：</span><span>'+ maintainObj.consultantName +'</span>'
					  								  +			'<span style="padding:0 0 0 20px">'+ maintainObj.consultantPhone +'</span>'
					  								  +			'<a href="tel:'+ maintainObj.consultantPhone +'" id="Tel">'
					  								  + 		'<span class="glyphicon glyphicon-earphone" style="padding:0 0 0 10px;color: rgb(255, 0, 23); font-size: 12px;"></span>'
					  								  + 		'</a>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +    '</ul>'
					  								  + '</div>'
					  								  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +		'<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">预约类型：</span><span>'+ maintainObj.appointType +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">联&nbsp;系&nbsp;人：</span><span>'+maintainObj.maintainName+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">手机号码：</span><span>'+maintainObj.phone+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">提交时间：</span><span>'+createDate+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">到店时间：</span><span>'+ reseApplStartTime +'</span>'
					  								  +		  '</p>'
					  								  +		 '</li>'
					  								  +	   '</ul>'
					  								  +	 '</div>'
					  								  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +     '<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">车牌号：</span><span>'+ maintainObj.licenseNo +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">车&nbsp;&nbsp;型：</span><span>'+ maintainObj.modelName +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">里&nbsp;&nbsp;程：</span><span>'+ maintainObj.mileage +'</span>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +	   '</ul>'
					  								  +	 '</div>'
						  							  + '<div class="panel panel-default">'
						  							  +   '<input style="background-color:#E50014;color:white" type="button" data-toggle="modal" data-target="#myModal"  value="取消预约" class="btn btn-default btn-lg btn-block" />'
						  							  + '</div>'
				}
				else if(maintainObj.status=="已养修"){
					
					maintainHtml = maintainHtml 	  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +     '<li class="list-group-item">'
					  								  +	      '<p>'
					  								  +		    '<span>'+ maintainObj.oddNumber +'</span>'
					  								  +		    '<span style="font-family:黑体;font-size:15px;color:#76CBFF;float:right">'+ maintainObj.status +'</span>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +     '<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">销售服务店：</span><span>'+ dealerName +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">地址：</span><span>'+ detailAddress +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">电话：</span><span>'+ serviceHotline +'</span>'
					  								  +			'<a href="tel:'+ maintainObj.serviceHotline +'" id="Tel">'
					  								  + 		'<span class="glyphicon glyphicon-earphone" style="padding:0 0 0 10px;color: rgb(255, 0, 23); font-size: 12px;"></span>'
					  								  + 		'</a>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">服务顾问：</span><span>'+ maintainObj.consultantName +'</span>'
					  								  +			'<span style="padding:0 0 0 20px">'+ maintainObj.consultantPhone +'</span>'
					  								  +			'<a href="tel:'+ maintainObj.consultantPhone +'" id="Tel">'
					  								  + 		'<span class="glyphicon glyphicon-earphone" style="padding:0 0 0 10px;color: rgb(255, 0, 23); font-size: 12px;"></span>'
					  								  + 		'</a>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +    '</ul>'
					  								  + '</div>'
					  								  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +		'<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">预约类型：</span><span>'+ maintainObj.appointType +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">联&nbsp;系&nbsp;人：</span><span>'+maintainObj.maintainName+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">手机号码：</span><span>'+maintainObj.phone+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">提交时间：</span><span>'+createDate+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">到店时间：</span><span>'+reseApplStartTime+'</span>'
					  								  +		  '</p>'
					  								  +		 '</li>'
					  								  +	   '</ul>'
					  								  +	 '</div>'
					  								  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +     '<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">车牌号：</span><span>'+ maintainObj.licenseNo +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">车&nbsp;&nbsp;型：</span><span>'+ maintainObj.modelName +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">里&nbsp;&nbsp;程：</span><span>'+ maintainObj.mileage +'</span>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +	   '</ul>'
					  								  +	 '</div>'
				}
				else{
					
					maintainHtml = maintainHtml 	  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +     '<li class="list-group-item">'
					  								  +	      '<p>'
					  								  +		    '<span>'+ maintainObj.oddNumber +'</span>'
					  								  +		    '<span style="font-family:黑体;font-size:15px;color:#B7B7B7;float:right">'+ maintainObj.status +'</span>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +     '<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">销售服务店：</span><span>'+ dealerName +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">地址：</span><span>'+ detailAddress +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">电话：</span><span>'+ serviceHotline +'</span>'
					  								  +			'<a href="tel:'+ maintainObj.serviceHotline +'" id="Tel">'
					  								  + 		'<span class="glyphicon glyphicon-earphone" style="padding:0 0 0 10px;color: rgb(255, 0, 23); font-size: 12px;"></span>'
					  								  + 		'</a>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">服务顾问：</span><span>'+ maintainObj.consultantName +'</span>'
					  								  +			'<span style="padding:0 0 0 20px">'+ maintainObj.consultantPhone +'</span>'
					  								  +			'<a href="tel:'+ maintainObj.consultantPhone +'" id="Tel">'
					  								  + 		'<span class="glyphicon glyphicon-earphone" style="padding:0 0 0 10px;color: rgb(255, 0, 23); font-size: 12px;"></span>'
					  								  + 		'</a>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +    '</ul>'
					  								  + '</div>'
					  								  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +		'<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">预约类型：</span><span>'+ maintainObj.appointType +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">联&nbsp;系&nbsp;人：</span><span>'+maintainObj.maintainName+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">手机号码：</span><span>'+maintainObj.phone+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">提交时间：</span><span>'+createDate+'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +		    '<span style="font-family:黑体;font-size:15px">到店时间：</span><span>'+reseApplStartTime+'</span>'
					  								  +		  '</p>'
					  								  +		 '</li>'
					  								  +	   '</ul>'
					  								  +	 '</div>'
					  								  + '<div class="panel panel-default">'
					  								  +   '<ul class="list-group">'
					  								  +     '<li class="list-group-item">'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">车牌号：</span><span>'+ maintainObj.licenseNo +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">车&nbsp;&nbsp;型：</span><span>'+ maintainObj.modelName +'</span>'
					  								  +		  '</p>'
					  								  +		  '<p>'
					  								  +			'<span style="font-family:黑体;font-size:15px">里&nbsp;&nbsp;程：</span><span>'+ maintainObj.mileage +'</span>'
					  								  +		  '</p>'
					  								  +		'</li>'
					  								  +	   '</ul>'
					  								  +	 '</div>'
				}
				
				wholeHtml += maintainHtml;
			});
			
			$("#information").append(wholeHtml);
		}
	});
	
	$('#modalSure').click(function(){
		var data={
		resnId:"",
		applyStatus:"",
    }; 
    data.resnId = $.trim($("#resnId").val()); 
    data.applyStatus = $.trim($("#applyStatus").val()); 
    
    
	$.ajax({
		headers: {'Cookie' : document.cookie },
		type : 'POST',
		url : rootPath+'/maintain/api/v1/updateMaintainStatus',
		contentType:"application/json",
		data: JSON.stringify(data),
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("失败");
		},
		success : function(data){
			$('#maintainModal').modal({
				keyboard: false,
				backdrop:false
			});
		}
	});
  });
})
function re(){
	window.location = rootPath + "/views/hpp.html";
}